<!--
  Generated template for the QuestionPage page.

  See http://ionicframework.com/docs/components/#navigation for more info on
  Ionic pages and navigation.
-->
<ion-header>
  <ion-navbar color="gm-primary">
    <ion-title>咨询列表</ion-title>
    <ion-buttons right *ngIf="user_info.type == 0 || user_info.type == 1">
      <button ion-button icon-only (click)="onNewQuestion()">
        <ion-icon name="create"></ion-icon>
      </button>
    </ion-buttons>
  </ion-navbar>
</ion-header>

<ion-content>
  <ion-refresher (ionRefresh)="onRefresh($event)" *ngIf="user_info.type >= 0">
    <ion-refresher-content
        pullingIcon="arrow-dropdown"
        pullingText="下拉开始刷新"
        refreshingSpinner="circles"
        refreshingText="数据正在载入">
    </ion-refresher-content>
  </ion-refresher>

  <ion-list *ngIf="question_list.length > 0">
    <ion-item-sliding *ngFor="let question of question_list">
      <ion-item class="question-item" (click)="onItemSelected(question)" tappable>
        <div class="content">{{question.content}}</div>
        <div class="date">{{question.updated_at|date:'yy年MM月dd日 HH点mm分'}}</div>
        <ion-badge item-end [color]="item_mark[question.read ? 1 : 0].color">{{item_mark[question.read ? 1 : 0].label}}</ion-badge>
      </ion-item>
      <ion-item-options side="right" *ngIf="user_info.type <= 1">
        <button ion-button color="danger" (click)="onItemDeleted(question)">
          <ion-icon name="gm-close"></ion-icon>
          关闭
        </button>
      </ion-item-options>
    </ion-item-sliding>
  </ion-list>

  <ion-infinite-scroll (ionInfinite)="onInfinite($event)" *ngIf="question_list.length < question_count">
    <ion-infinite-scroll-content
        loadingSpinner="bubbles"
        loadingText="数据正在载入">
    </ion-infinite-scroll-content>
  </ion-infinite-scroll>

  <div *ngIf="question_list.length == 0 && user_info.type >= 0" class="no-data">
    <img src="assets/icon/empty.png">
    <div>您还没有咨询的问题</div>
  </div>

  <div *ngIf="user_info.type < 0" class="no-data" padding>
    <h5>登录后可以咨询问题</h5>
    <button ion-button full (click)="onUserLogin()">用户登录</button>
  </div>
</ion-content>
